var onShowDialog=null;
function SkylineDialog(title,content,width,objectId){
	this.title=title;
	this.content=content;
	this.object=objectId;
	this.isMouseDown=false;
	this.initaled=false;
	this.pX=0;
	this.pY=0;
	this.width=width;
	this.isIE=false;
	this.clsBtn='/skyline/plugin/skylinedialog/img/close.png';
	this.mouseDown=function(e){
		var event=e||window.event;
		//if(event) alert();
		//if(document.getElementById(this.object).style.pixelLeft){
			//this.pX=event.clientX-document.getElementById(this.object).style.left;
			this.pX=event.clientX-document.getElementById(this.object).style.left.substring(0,document.getElementById(this.object).style.left.length-2);
		//}
		//alert(event.clientX-document.getElementById(this.object).style.left.substring(0,document.getElementById(this.object).style.left.length-2));
		//if(document.getElementById(this.object).style.pixelTop){
			//this.pY=event.clientY-document.getElementById(this.object).style.top;
			this.pY=event.clientY-document.getElementById(this.object).style.top.substring(0,document.getElementById(this.object).style.top.length-2)
		//}
		this.isMouseDown=true;
		onShowDialog=this;
		document.onmousemove=this.mouseMove;
		document.onmouseup=this.mouseUp;
	}

	this.mouseMove=function(e){
		var event=e||window.event;
		if(onShowDialog&&onShowDialog.isMouseDown==true) {
			if(this.isIE){
				document.getElementById(onShowDialog.object).setCapture();
			}else{
				// window.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP);    
			}
			//alert(event.clientX+"|"+onShowDialog.pX);
			if(event.clientX-onShowDialog.pX>0){
				document.getElementById(onShowDialog.object).style.left=(event.clientX-onShowDialog.pX)+"px";
			}else{
				document.getElementById(onShowDialog.object).style.left="0px";
			}
			if(event.clientY-onShowDialog.pY>0){
				document.getElementById(onShowDialog.object).style.top=(event.clientY-onShowDialog.pY)+"px";
			}else{
				document.getElementById(onShowDialog.object).style.top="0px";
			}
		}
	}

	this.mouseUp=function(){
		if(this.isIE){
			document.getElementById(onShowDialog.object).releaseCapture();
		}else{
			//window.releaseEvents(Event.MOUSEMOVE|Event.MOUSEUP);  
		}
		onShowDialog.isMouseDown=false;
	}
	
	this.inital=function(){
		if (window.innerWidth) {
		    theWidth = window.innerWidth;
		    theHeight = window.innerHeight;
		} else if (document.compatMode == 'CSS1Compat') {
		    theWidth = document.documentElement.clientWidth;
		    theHeight = document.documentElement.clientHeight;
		} else if (document.body) {
		    theWidth = document.body.clientWidth;
		    theHeight = document.body.clientHeight;
		}
		var dialogHtml="";
		var left=(theWidth-this.width)/2+"px";
		var top=(theHeight)/5+"px";
		dialogHtml+="<div class='SkylineDialog' style='top:"+top+";left:"+left+";width:"+this.width+"px' id='"+this.object+"' >";
		dialogHtml+="<table class='SkylineDialogBody'>";
		dialogHtml+="<tr class='SkylineDialogTitle' onmousedown='"+this.object+".mouseDown(event)'><td>"+title+"<\/td><td width='20px'><a href='javascript:"+this.object+".close()'><img width='16px' src='"+this.clsBtn+"'><\/td><\/a><\/tr>";
		dialogHtml+="<tr><td>"+content+"<\/td><\/tr>";
		dialogHtml+="<\/table>";
		dialogHtml+="<\/div>";
		document.writeln(dialogHtml);
		this.initaled=true;
		if(!-[1,]){
		    this.isIE=true;
		}else{
			 this.isIE=false;
		}
	}
	
	this.show=function (){
		if(onShowDialog){
			onShowDialog.close();
		}
		if(this.initaled==false){
			this.inital();
		}
		document.getElementById(this.object).style.display='block';
		onShowDialog=this;
		this.isMouseDown=false;
	}
	this.close=function (){
		document.getElementById(this.object).style.display='none';
		this.isMouseDown=false;
	}
	this.inital();
}